package com.example.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/BMLServelt")
public class BMLServelt extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html;charset=utf-8");
		
		String weight =req.getParameter("weight");
		String height =req.getParameter("height");
		int w = Integer.parseInt(weight);
		double h = Double.parseDouble(height);
		
		PrintWriter pw = resp.getWriter();
		double bml=w/(h*h);
		String x = String.valueOf(bml);
		pw.write(x);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}